package com.bbx.api.gclient;


import com.gim.client;

import android.content.Context;
import android.content.IntentFilter;




/**
 * 客户端的一些实例化，注册监听，获取client对象进行调用要执行的方法
 */
public class GClientBox {
	/**客户端*/
	private client mClient;
	/**监听器，监听SDK返回的结果*/
	private GMsgListener mGMsgListener;
	/**实例化推送类*/
	private GMsgPublisher mPublisher;
	private static GClientBox ins = null;
	public static GClientBox instance(){
		if(ins == null){
			ins = new GClientBox();
		}
		return ins;
	}
	/**
	 *获取客户端
	 */
	public client getClient(){
		return mClient;
	}
	/**
	 * 获取推送类
	 */
	public GMsgPublisher getPublisher(){
		return mPublisher;
	}
	public void init(Context context){
		//实例化推送类
		mPublisher = new GMsgPublisher();
		//注册广播
		IntentFilter filter = new IntentFilter();
		filter.addAction(GMsgBroadcastReceiver.TAG);
		filter.setPriority(Integer.MAX_VALUE);
		context.registerReceiver(new GMsgBroadcastReceiver(), filter);
		//监听
		mGMsgListener = new GMsgListener(context);
		//实例化客户端
		mClient = new client();
		mClient.init(mGMsgListener);
	}
}
